//
//  CZQMansoryController.m
//  CZQStudyDemo
//
//  Created by 陈志强 on 2019/11/28.
//  Copyright © 2019 陈志强. All rights reserved.
//

#import <Masonry.h>
#import "CZPerson.h"
#import "CZQMansoryController.h"

@interface CZQMansoryController ()

@end

@implementation CZQMansoryController

- (void)viewDidLoad {
    [super viewDidLoad];
 
    self.view.backgroundColor = [UIColor whiteColor];
    _name = @"you are best man in china";
//    [self loadCustomTestView];
    
    CZPerson *person = [[CZPerson alloc] init];
//    person.loadName = ^NSString * _Nonnull(NSString * _Nonnull firstName) {
//        return @"chen";
//    };    
    NSInteger cur  = person.allName(@"zhi").length;
    
}

- (id)initWithName:(NSString *)name{
    self = [super init];
    if (!self) return nil;
    _name = name;
    
    return self;
}

- (void)testName:(NSString *)name{
    _name = name;
}

- (void)loadCustomTestView{
    UIView *testView = [[UIView alloc] init];
    testView.backgroundColor = [UIColor yellowColor];
    [self.view addSubview:testView];
    [testView mas_makeConstraints:^(MASConstraintMaker *make) {
        //test1
        make.edges.equalTo(self.view).inset(20);
        
        //test2
        //make.size.equalTo(self.view).sizeOffset(CGSizeMake(100, -100));
        //make.center.equalTo(self.view);
        
        //test3
//        make.size.mas_equalTo(CGSizeMake(100, 100));
//        make.center.equalTo(self.view).centerOffset(CGPointMake(-130, 60));
      
        //test4
//        make.left.equalTo(self.view.mas_left).valueOffset(@15);
//        make.centerY.equalTo(self.view.mas_centerY);
//        NSValue *equ = [NSValue valueWithCGSize:CGSizeMake(100, 100)];
//        make.size.valueOffset(equ);
        
        //test5
//        make.size.equalTo(self.view).dividedBy(2.0);
//        make.center.equalTo(self.view);
        
        //test6
//        make.width.equalTo(self.view.mas_width).multipliedBy(0.5);
//        make.height.equalTo(@100);
//        make.center.equalTo(self.view);
        
        //test7
        make.left.equalTo(self.view.mas_left).mas_offset(10);
        /**
        1、通过点语法 调用[self addConstraintWithLayoutAttribute:NSLayoutAttributeLeft];
        2、[self addConstraintWithLayoutAttribute:NSLayoutAttributeLeft];
           实际调用方法[self constraint:nil addConstraintWithLayoutAttribute:NSLayoutAttributeLeft];
        3、生成MASViewAttribute（如果constraint存在，就生成一个组约束对象MASCompositeConstraint，不存在的话，就简单的生成一个约束对象MASViewConstraint，然后返回），同时将constraint添加到数组里
         
         equaltoRelation 最终调用的是子类的self.equalToWithRelation(attribute, NSLayoutRelationEqual);
         方法，然后最终返回MASConstraint
        */
    }];
}

@end
